package com.bjesc_b2c.app.appraiset.adapter;

import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import com.bjesc_b2c.app.appraiset.R;
import com.bjesc_b2c.app.appraiset.bean.AudiOrderBean;

import java.util.List;
import app.pinggushi.bjesc.com.baserecyclerview.adapter.CommonAdapter;
import app.pinggushi.bjesc.com.baserecyclerview.adapter.base.ViewHolder;

/**
 * Created by yidong on 2017/9/1.
 */

public class AudioInfoAdapter<T> extends CommonAdapter<T> {
    public AudioInfoAdapter(Context context, int layoutId, List<T> datas) {
        super(context, layoutId, datas);
    }
    @Override
    protected void convertView(ViewHolder holder, Object o, int position) {
        if (o instanceof AudiOrderBean.TouTrailBean) {
            AudiOrderBean.TouTrailBean bean = (AudiOrderBean.TouTrailBean) o;
            holder.setText(R.id.tv_time, bean.getAdd_time());
            holder.setText(R.id.tv_type, bean.getType());
            holder.setText(R.id.tv_content, bean.getContent());
            holder.setVisible(R.id.tv_car_title,false);
            holder.setVisible(R.id.item_recycler_view,false);
        } else if (o instanceof AudiOrderBean.DispatchTrailBean) {
            AudiOrderBean.DispatchTrailBean bean = (AudiOrderBean.DispatchTrailBean) o;
            holder.setText(R.id.tv_time, bean.getAdd_time());
            holder.setText(R.id.tv_type, bean.getType());
            holder.setText(R.id.tv_content, bean.getContent());
            holder.setVisible(R.id.tv_car_title,false);
            if (bean.getPath()!= null && bean.getPath().size()>0 ){
                RecyclerView recyclerView = holder.getView(R.id.item_recycler_view);
                recyclerView.setLayoutManager(new LinearLayoutManager(mContext,LinearLayoutManager.HORIZONTAL,false));
                recyclerView.setAdapter(new AudioFollowPhotoAdapter(mContext, R.layout.layout_item_follow_photo, bean.getPath()));
            }
        }else if (o instanceof AudiOrderBean.LikeCarsBean) {
            AudiOrderBean.LikeCarsBean bean = (AudiOrderBean.LikeCarsBean) o;
            holder.setText(R.id.tv_time, bean.getAdd_time());
            holder.setText(R.id.tv_type, bean.getCar_id());
            holder.setText(R.id.tv_content, bean.getOperation_name());
            holder.setText(R.id.tv_car_title, bean.getTitle());
            holder.setVisible(R.id.item_recycler_view,false);
        }
    }
}
